﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Conteinerid.Aspects
{
    public class AdviceVisitor
    {
        public void Execute(EventHandlerList eventos, ToInvokeWhen toInvokeWhen, string methodName, IEnumerable<NamedParameter> parameters)
        {
            List<string> l = new List<string>();
            foreach (var item in parameters)
            {
                l.Add(item.Type.Name);
            }

            var s = string.Format("{0}{1}{2}", methodName, string.Join("", l.ToArray()), toInvokeWhen.ToString());
            EventArgs args = new AspectEventArgs()
            {
                MethodName = methodName,
                Parameters = new List<NamedParameter>(parameters)
            };
            ((EventHandler)eventos[s])(this, args);
        }
    }
}
